今天去參加了鐵人賽,才知道原來考試的題目是類似於給你個程式碼,問你這會造成什麼樣的攻擊,我是覺得蠻酷的啦。我還是想再解一題我試試看,不行再回來寫理論吧!
題目:Classic Crackme 0x100
input[i_0] = ((random2 & secret3) + input[i_0] - fix + (secret3 & (random2 >> 4))) % 26 + fix;
input[i_0] = (input[i_0]-fix+ (random2 & secret3)+(secret3 & (random2 >> 4)))%26+fix
逆向時要反著看,以e_intput[i_0]代表加密後的input,原始的input就叫input:input = e_intput[i_0] - fix
(因為最後面再加密時加上了fix)input = e_intput[i_0] - fix
(原本的mod26不需要去限制(不然y會出不來)
input = (e_intput[i_0] - fix -(secret3 & (random2 >> 4)-(random2 & secret3))%26+fix
def decrypto(e_input):
secret1 = 85
secret2 = 51
secret3 = 15
fix = 97
for i in range(3):
for i_0 in range(len(e_input)):
random1 = (secret1 & (i_0 % 255)) + (secret1 & (i_0 % 255) >> 1)
random2 = (random1 & secret2) + (secret2 & (random1 >> 2))
e_input[i_0] = chr(((ord(e_input[i_0]) - fix - (random2 & secret3) - (secret3 & (random2 >> 4))) % 26) + fix)
e_input = list("mpknnphjngbhgzydttvkahppevhkmpwgdzxsykkokriepfnrdm")
decrypto(e_input)
print("".join(e_input))
後記:
又多活了一天,這題是真的好難啊...快掛了